package com.bayi.storage.network.entity;

import java.io.Serializable;
import java.lang.reflect.Field;

/**
 * Created by guoping on 16/9/5.
 */
public class CanCopyModel implements Serializable {
    public <T> T copy() {
        try {
            T t = (T) getClass().newInstance();
            for (Field f : getClass().getDeclaredFields()) {
                f.setAccessible(true);
                f.set(t, f.get(this));
            }
            return t;
        }catch (Exception ex) {
            ex.printStackTrace();
            return null;
        }
    }
}
